package com.lanou3g.ptp.taskrole.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.lanou3g.ptp.entity.TaskRole;
import com.lanou3g.ptp.taskrole.mapper.TaskRoleMapper;
import com.lanou3g.ptp.taskrole.service.TaskRoleService;
import org.springframework.beans.factory.annotation.Autowired;


import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class TaskRoleServiceImpl implements TaskRoleService {

    @Autowired
    private TaskRoleMapper taskRoleMapper;

    @Override
    public List<TaskRole> findAll(Integer page, Integer size) {
        PageHelper.startPage(page, size);

        return taskRoleMapper.findAll();
    }


    @Override
    public TaskRole findById(Long id) {
        return taskRoleMapper.findById(id);
    }

    @Override
    public void insert(ArrayList<TaskRole> taskRoles) {
        taskRoleMapper.inserts(taskRoles);
    }

    @Override
    public void update(Long id, TaskRole taskRole) {
        taskRole.setUpdateTime(new Date());
        taskRoleMapper.update(id, taskRole);
    }

    @Override
    public void delete(Long id) {
        taskRoleMapper.delete(id);
    }

    @Override
    public void deletes(Long[] ids) {
        taskRoleMapper.deletes(ids);
    }

    @Override
    public void deleteByTaskId(Long taskId) {
        taskRoleMapper.deleteByTaskId(taskId);
    }

    @Override
    public TaskRole findByRoleId(Long roleId) {
        TaskRole taskRole = taskRoleMapper.findByRoleId(roleId);
        return taskRole;
    }

    @Override
    public ArrayList<TaskRole> findByTaskId(Long taskId) {
        ArrayList<TaskRole> taskRoles = taskRoleMapper.findByTaskId(taskId);
        return taskRoles;
    }

    @Override
    public void deletesByTaskIds(Long[] ids) {
        taskRoleMapper.deletesByTaskIds(ids);
    }

}
